﻿using Inventorycount.API.Read.Application.Command;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Inventorycount.API.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TransfeController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly ILogger<TransfeController> logger;
        public TransfeController(IMediator mediator, ILogger<TransfeController> logger)
        {
            _mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 调拨
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetTransfe([FromQuery] GetTransfeCommand command)
        {
            logger.LogInformation("调拨显示成功");
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 商品
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetGoods()
        {
            logger.LogInformation("商品显示成功");
            GetGoodsCommand command = new GetGoodsCommand();
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 仓库
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetWarehouse()
        {
            logger.LogInformation("仓库显示成功");
            GetWarehouseCommand command = new GetWarehouseCommand();
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 用户
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetUser()
        {
            logger.LogInformation("用户显示成功");
            GetUserCommand command = new GetUserCommand();
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 出库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Getoutbound(int id)
        {
            logger.LogInformation("出库显示成功");
            GetoutboundCommand command = new GetoutboundCommand()
            {
                Transfer_id = id
            };
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 操作列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetLog([FromQuery]GetLogCommand command)
        {
            logger.LogInformation("操作显示成功");
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 入库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Geinbound(int id)
        {
            logger.LogInformation("出库显示成功");
            GetinboundCommand command = new GetinboundCommand()
            {
                Transfer_id = id
            };
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 库存
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GeInventory([FromQuery]GetInventoryCommand command)
        {
            logger.LogInformation("出库显示成功");
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 入库审批表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetInboundorder([FromQuery] GetInboundorderCommand command)
        {
            logger.LogInformation("入库审批表信息显示成功");
            var result = await _mediator.Send(command);
            return Ok(result);
        }
        /// <summary>
        /// 出库审批表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Getoutboundorder([FromQuery] GetoutboundorderCommand command)
        {
            logger.LogInformation("出库审批表信息显示成功");
            var result = await _mediator.Send(command);
            return Ok(result);
        }
    }
}
